/*
 *  Copyright © 2010 by Rob Cash
 * 
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 * LoginForm.java
 * 
 * Created on Jul 8, 2010 at 3:26:41 PM
 */

package org.robcash.commons.components.jdesktop;

/**
 * Swing form to collect a user ID and password. This component does not
 * perform a login.
 * @author Rob Cash
 */
public class LoginForm extends javax.swing.JPanel {

	/**
	 * Serialization ID
	 */
	private static final long serialVersionUID = -1592678991326345794L;

	/** Creates new form LoginForm */
	public LoginForm()
	{
		initComponents();
	}

	/**
	 * Get the user ID that was entered into the form
	 * @return User ID
	 */
	public String getUserId()
	{
		return userIdTextField.getText();
	}

	/**
	 * Get the password that was entered into the form
	 * @return Password
	 */
	public String getPassword()
	{
		return new String(passwordField.getPassword());
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
	// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		userIdLabel = new javax.swing.JLabel();
		userIdTextField = new javax.swing.JTextField();
		passwordLabel = new javax.swing.JLabel();
		passwordField = new javax.swing.JPasswordField();

		setName("Form"); // NOI18N

		userIdLabel.setLabelFor(userIdTextField);
		userIdLabel.setText(org.jdesktop.application.Application.getInstance().getContext().getResourceMap(LoginForm.class).getString("userIdLabel.text")); // NOI18N
		userIdLabel.setName("userIdLabel"); // NOI18N

		userIdTextField.setText(org.jdesktop.application.Application.getInstance().getContext().getResourceMap(LoginForm.class).getString("userIdTextField.text")); // NOI18N
		userIdTextField.setName("userIdTextField"); // NOI18N

		passwordLabel.setText(org.jdesktop.application.Application.getInstance().getContext().getResourceMap(LoginForm.class).getString("passwordLabel.text")); // NOI18N
		passwordLabel.setName("passwordLabel"); // NOI18N

		passwordField.setText(org.jdesktop.application.Application.getInstance().getContext().getResourceMap(LoginForm.class).getString("passwordField.text")); // NOI18N
		passwordField.setName("passwordField"); // NOI18N

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout.setHorizontalGroup(
				layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup()
						.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
								.addComponent(passwordLabel)
								.addComponent(userIdLabel))
								.addGap(28, 28, 28)
								.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
										.addComponent(passwordField)
										.addComponent(userIdTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)))
				);
		layout.setVerticalGroup(
				layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(layout.createSequentialGroup()
						.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(userIdTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
								.addComponent(userIdLabel))
								.addGap(14, 14, 14)
								.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
										.addComponent(passwordField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
										.addComponent(passwordLabel)))
				);
	}// </editor-fold>//GEN-END:initComponents


	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JPasswordField passwordField;
	private javax.swing.JLabel passwordLabel;
	private javax.swing.JLabel userIdLabel;
	private javax.swing.JTextField userIdTextField;
	// End of variables declaration//GEN-END:variables

}
